# -*- coding: utf-8 -*-
#coding=utf-8
# 先导入后续要使用的包
import time,pyautogui
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver import ActionChains
# 创建一个webDriver的实例，接下来的所有操作都是在该实例上进行，以Chrome实例为例
driver = webdriver.Chrome()
#窗口最大化
driver.maximize_window()
# 访问德科数智系统
driver.get("http://172.16.70.246/login")
driver.implicitly_wait(5)
# 通过元素id找到对应元素并输入值进行搜索；此处为在百度搜索框输入selenium并点击查询
driver.find_element(By.XPATH,"//input[@placeholder='账号名称']").send_keys("20280")
driver.find_element(By.XPATH,"//input[@placeholder='密码']").send_keys("000000")
driver.find_element(By.XPATH,"//span[text()='登录']").click()
driver.find_element(By.XPATH,"//span[text()='客户关系管理']").click()
driver.find_element(By.XPATH,"//span[text()='客户列表']").click()
# a=ActionChains(driver)
# a.click(driver.find_element(By.XPATH,'//*[@id="card"]/div/div[1]/div/div[2]/div[2]/div[2]/div[2]/table/tbody/tr[3]/td[11]/div/div/div[2]/div/span[2]')).perform()

# time.sleep(1)
# driver.find_element(By.XPATH,"//span[text()='壳牌公司']").click()
# handles = driver.window_handles
# driver.switch_to.window(handles[-1])
time.sleep(1)
# driver.find_element(By.XPATH,"//span[text()='跟进']").click()
driver.find_element(By.XPATH,'//div[@id="card"]/div/div[1]/div/div[2]/div[1]/div[2]/table/tbody/tr[3]/td[11]/div/div/div[1]/div/span').click()
driver.find_element(By.XPATH,'//*[@id="right-main-container"]/div[2]/div[4]/div/div[2]/div/div[1]/div/form/div[1]/div[2]/div/div[2]/div/div/div').click()
driver.find_element(By.XPATH,"//span[text()='商机100']").click()
driver.find_element(By.XPATH,'//*[@id="right-main-container"]/div[2]/div[4]/div/div[2]/div/div[1]/div/form/div[1]/div[3]/div/div[2]/div/div/div[1]').click()
driver.find_element(By.XPATH,"//span[text()='邱女士']").click()
driver.find_element(By.XPATH,'//*[@id="right-main-container"]/div[2]/div[4]/div/div[2]/div/div[1]/div/form/div[1]/div[6]/div/div[2]/div/div/div[1]').click()
time.sleep(2)
driver.find_element(By.XPATH,"//span[text()='xyz5自定义事业群']").click()
driver.find_element(By.XPATH,'//*[@id="right-main-container"]/div[2]/div[4]/div/div[2]/div/div[1]/div/form/div[1]/div[7]/div/div[2]/div/div').click()
driver.find_element(By.XPATH,'//*[@id="right-main-container"]/div[2]/div[4]/div/div[2]/div/div[1]/div/form/div[1]/div[7]/div/div[2]/div/div/textarea').send_keys(u'sdjskdsdsjkdjsddks')
driver.find_element(By.XPATH,'//*[@id="right-main-container"]/div[2]/div[4]/div/div[2]/div/div[1]/div/form/div[1]/div[8]/div/div[2]/div/div').click()
# time.sleep(2)
# driver.find_element(By.XPATH,'/html/body/div[5]/div[1]/div/div[1]/button[2]').click()
time.sleep(3)
driver.find_element(By.XPATH,"//span[contains(text(),'13')]  ").click()
driver.find_element(By.XPATH,'//*[@id="right-main-container"]/div[2]/div[4]/div/div[2]/div/div[1]/div/form/div[1]/div[9]/div/div[2]/div/div/div').click()
driver.find_element(By.XPATH,"//span[text()='客户中高层约谈']").click()
driver.find_element(By.XPATH,'//*[@id="right-main-container"]/div[2]/div[4]/div/div[2]/div/div[1]/div/form/div[1]/div[10]/div/div[2]/div/div/div').click()
driver.find_element(By.XPATH,"//span[text()='现场拜访']").click()
driver.find_element(By.XPATH,'//*[@id="right-main-container"]/div[2]/div[4]/div/div[2]/div/div[1]/div/form/div[1]/div[11]/div/div[2]/div/div/input').send_keys(u'sjdksd第三节课大家说的倒计时大开杀戒是的')
driver.find_element_by_xpath("//span[text()='上传']").click()
time.sleep(2)
data=r'D:\1.jpg'
data.encode('utf8')
pyautogui.typewrite(data)
time.sleep(1)
pyautogui.press("ENTER")
pyautogui.press("ENTER")
time.sleep(1)
driver.find_element_by_xpath("//span[text()='提交']").click()
driver.find_element_by_xpath("//span[text()='跟进记录']").click()


